package com.example.neusoft.yuejian_12.Adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.neusoft.yuejian_12.JavaBean.Photo;
import com.example.neusoft.yuejian_12.R;

import org.w3c.dom.Comment;

import java.util.List;

/**
 * Created by 晓真 on 2017/10/10.
 */

public class PhotoInfoAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{
    private Context mContext;
    private List mDataList;//数据存储
    private LayoutInflater mLayoutInflater;//准备布局


    public PhotoInfoAdapter(Context mContext, List mDataList){
        this.mContext=mContext;
        this.mDataList=mDataList;
        mLayoutInflater = LayoutInflater.from(mContext);
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
    {
        View v = mLayoutInflater.from(parent.getContext()).inflate(R.layout.photoinfo_item, parent, false);
        return new PhotoInfoAdapter.ViewHolder(v);
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {

        final Photo.CommentEntity entity = (Photo.CommentEntity) mDataList.get(position);
        if (null == entity)
            return;
        PhotoInfoAdapter.ViewHolder viewHolder = (PhotoInfoAdapter.ViewHolder) holder;

        viewHolder.username.setText(entity.getReply_userid());
        viewHolder.comment.setText(entity.getReply());
        viewHolder.time.setText(entity.getReply_time());
        //glide方法
        // Glide.with(mContext).load(entity.getPic()).into(viewHolder.imageView);

    }

    @Override
    public int getItemCount()
    {
        return mDataList.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder{

        TextView comment,username,time;

        public ViewHolder(View itemView) {
            super(itemView);
            username = (TextView) itemView.findViewById(R.id.photo_info_comment_user);
            comment = (TextView) itemView.findViewById(R.id.photo_info_comment_comment);
            time = (TextView) itemView.findViewById(R.id.photo_info_comment_time);

        }
    }

}
